package com.gxa.jjty.admin.controller;

import com.github.pagehelper.PageInfo;
import com.gxa.jjty.admin.service.ComplaintService;
import com.gxa.jjty.core.common.JsonResult;
import com.gxa.jjty.core.pojo.Complaint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName ComplaintController
 * @Author: ws
 * @date 2021/12/9 9:40
 */
@RestController
@RequestMapping("/complaint")
@Api(tags = "意见投诉管理的接口")
public class ComplaintController {

    @Autowired
    private ComplaintService complaintService;

    @GetMapping("/getAll")
    @ApiOperation("分页全查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "页数",dataType = "Integer",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页记录数",dataType = "Integer",paramType = "query")
    })
    public Map getAll(@RequestParam("page") Integer page,
                      @RequestParam("size") Integer size
    ) throws IllegalAccessException {

        PageInfo<Complaint> pageInfo = complaintService.selectByPage(page, size);

        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("1");
        jsonResult.setData(pageInfo.getList());
        jsonResult.put("total", pageInfo.getTotal());

        return jsonResult.getDataMap();
    }

}
